import os
import requests

ALIYUN_API_KEY = os.getenv("ALIYUN_API_KEY")
MODEL_ENDPOINT = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation"

def call_llm_with_prompt(prompt: str) -> str:
    headers = {
        "Authorization": f"Bearer {ALIYUN_API_KEY}",
        "Content-Type": "application/json"
    }

    payload = {
        "model": "qwen-plus",
        "input": {
            "prompt": prompt
        }
    }

    response = requests.post(MODEL_ENDPOINT, headers=headers, json=payload)
    result = response.json()

    return result["output"]["text"]